package com.itheima.Demo01.demo03;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

public class NewInstance02 {
    public static void main(String[] args) throws Exception {
        //创建反射获取的对象
        Class aClass = Class.forName("com.itheima.Demo01.demo03.Student");
        //
        Object o = aClass.newInstance();
        System.out.println(o);
        Field[] fields = aClass.getDeclaredFields();
        for (Field field : fields) {
            System.out.println(field);
        }

        System.out.println("----");

        Field b = aClass.getDeclaredField("b");
        b.set(o,30);
        System.out.println(o);

        Object o1 = b.get(o);
        System.out.println(o1);
    }
}
